package start.doubudouyin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import start.doubudouyin.entity.Follow;
import start.doubudouyin.service.FollowService;
import start.doubudouyin.mapper.FollowMapper;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author mmmm
* @description 针对表【follow(关注表)】的数据库操作Service实现
* @createDate 2025-06-09 14:25:31
*/
@Service
public class FollowServiceImpl extends ServiceImpl<FollowMapper, Follow>
    implements FollowService{

    @Resource
    private FollowMapper  followMapper;

    @Override
    public boolean insert(String followerId, String followedId) {
        Follow follow = new Follow();
        follow.setFollowerId(followerId);
        follow.setFollowedId(followedId);
        Date date = new Date();
        follow.setFollowTime(date);
        return followMapper.insert(follow) > 0;
    }

    public Follow isFollow(String followerId,String followedId){
        return followMapper.isFollow(followerId,followedId);
    }

    public Integer GetFollowedCount(String userId){
        return followMapper.GetFollowedCount(userId);
    }
    public Integer GetFansCount(String userId){
        return followMapper.GetFansCount(userId);
    }

    public  List<String> getfirendId(String followerId){
        return followMapper.getfirendId(followerId);
    }
    public List<String> getfollowedId(String followerId){
        return followMapper.getfollowedId(followerId);
    }
    public Boolean isFollowed(String followerId,String followedId){
        return followMapper.isFollowed(followerId,followedId);
    }
    public Boolean isFriend(String followerId,String followedId){
        return followMapper.isFriend(followerId,followedId);
    }
    public Integer removeFollowed(String followerId,String followedId){
        return followMapper.removeFollowed(followerId,followedId);
    }

    @Override
    public void updatechat(String senderId, String receiverId) {
        followMapper.updatechat(senderId,receiverId);
    }

    @Override
    public List<String> getFollowers(String userId) {
        List<String> followers =followMapper.getfollowers(userId);
        return followers;
    }
}




